﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

/// <summary>
/// Summary description for CategoryBus
/// </summary>
public class CategoryBus
{
    CategoryDAL categoryDAL = new CategoryDAL();

	public CategoryBus()
	{
	}

    public DataTable GetAllCategory()
    {
        return categoryDAL.GetAllCategory();
    }

    public DataTable GetCategoryByID(int category_id)
    {
        return categoryDAL.getCategoryByID(category_id);
    }

    public int InsertCategory(string category_name, string category_des, string category_image, int parent_id)
    {
        category c = new category();
        c.CategoryName = category_name;
        c.CategoryDes = category_des;
        c.CategoryImage = category_image;
        c.ParentID = parent_id;

        int result = categoryDAL.InsertCategory(c);

        return result;
    }

    public int UpdateCategory(int category_id, string category_name, string category_des, string category_image, int parent_id)
    {
        category c = new category();
        c.CategoryID = category_id;
        c.CategoryName = category_name;
        c.CategoryDes = category_des;
        c.CategoryImage = category_image;
        c.ParentID = parent_id;
        
        int result = categoryDAL.UpdateCategory(c);

        return result;
    }

    public int DeleteCategory(int category_id)
    {
        return categoryDAL.DeleteCategory(category_id);
    }
}